package com.fr.report.cellElement;

import com.fr.base.FCloneable;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.data.Dictionary;
import com.fr.data.core.DataXMLUtils;
import com.fr.report.script.Calculator;

public class DictPresent extends AbstractPresent
{
  private Dictionary dict;

  public DictPresent()
  {
  }

  public DictPresent(Dictionary paramDictionary)
  {
    this.dict = paramDictionary;
  }

  public Dictionary getDictionary()
  {
    return this.dict;
  }

  public void setDictionary(Dictionary paramDictionary)
  {
    this.dict = paramDictionary;
  }

  public void reset()
  {
    this.dict.reset();
  }

  public String[] dependence()
  {
    return ((this.dict == null) ? new String[0] : this.dict.getDependence());
  }

  public Object present(Object paramObject, Calculator paramCalculator)
  {
    if ((this.dict == null) || (paramObject == null))
      return super.present(paramObject, paramCalculator);
    if (paramObject instanceof Formula)
      paramObject = ((Formula)paramObject).getResult();
    Object localObject = this.dict.get(paramObject, paramCalculator);
    return ((localObject == null) ? paramObject : localObject);
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str = paramXMLableReader.getTagName();
      if (("Dictionary".equals(str)) || ("Dict".equals(str)))
        this.dict = DataXMLUtils.readXMLDictionary(paramXMLableReader);
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if (this.dict != null)
      DataXMLUtils.writeXMLDictionary(paramXMLPrintWriter, this.dict);
  }

  public boolean equals(Object paramObject)
  {
    return ((paramObject instanceof DictPresent) && (ComparatorUtils.equals(this.dict, ((DictPresent)paramObject).dict)));
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    DictPresent localDictPresent = (DictPresent)super.clone();
    if (this.dict != null)
      localDictPresent.dict = ((Dictionary)this.dict.clone());
    return localDictPresent;
  }
}